<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    //验证0~255数字，每一位都要验证
    var reg =/^(\d|\d{2}|1\d{2}|2[0-4]\d|25[0-5])$/
    var str =300
    console.log(reg.test(str));
    
</script>